/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itschapala.dsw2.vista;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author RaygozaL
 */
@ManagedBean
@SessionScoped
public class AccessBean {
    //----------- variables (propiedades)
    
    private String name;
    private String pass;
    
    
    //------- contructores

    
    public AccessBean() {
    }
    
    //--------- metodos get y set

    public void setName(String name) {
        System.out.println("entro al set");
        this.name = name;
    }
    

    public String getName() {
        System.out.println("entro al get");
        return name;
    }

    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }
    
    //---------------------acciones----------
    
    public String validarLogin(){
       
        
        
    if(name.equals("root")&&pass.equals(("12345"))){
         FacesContext context=FacesContext.getCurrentInstance();
        context.getExternalContext().getSessionMap().put("USUARIO_LOGEADO",name);
    return  "MenuPrincipal";
    }else{
        return "pagina2";
    }
    }
    
    //----------listenerns----------------
    
}
